package module;

import java.io.FileNotFoundException;

public class GameObjectInitializer<G extends core.GameObject>
{
	public GameObjectInitializer(String moduleName, String initFileName) throws FileNotFoundException {
		interp = new org.python.util.PythonInterpreter();
		java.io.FileInputStream initFile;
		try {
			initFile = new java.io.FileInputStream("modules/" + moduleName + "/" + initFileName + ".py");
		} catch (java.io.FileNotFoundException e) {
			initFile = new java.io.FileInputStream("modules/default_init.py");
		}
		interp.execfile(initFile);
	}

	@SuppressWarnings("unchecked")
	public java.util.List<commands.Command> init(G gameObject) {
		interp.set("g", gameObject);
		interp.exec("commands = init(g)");
		return (java.util.List<commands.Command>)interp.get("commands", java.util.List.class);
	}

	private final org.python.util.PythonInterpreter interp;
}